package com.tigerCar.serviceOrder.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tiger.order.pojo.ServiceOrder;
import com.tigerCar.serviceOrder.server.ServiceProviderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.web.bind.annotation.*;

/**
 * chenzumao
 * 2021/4/21
 */
@RestController
@Slf4j
public class ServiceProviderController {
    @Autowired
    private ServiceProviderService serviceProviderService;

    /**
     * 订单管理-订单服务    查看所有服务订单
     * @param page
     * @param pagesize
     * @return
     */
    @GetMapping("/service/{page}/{pagesize}")
    public ResponseEntity<Page<ServiceOrder>> allServiceOrder(@PathVariable("page") Integer page,
                                                              @PathVariable("pagesize") Integer pagesize){
        log.info("订单管理-订单服务");
        Page<ServiceOrder> pageresult = serviceProviderService.allServiceOrder(page,pagesize);
        return ResponseEntity.ok(pageresult);
    }

    @PostMapping("/serviceProvider/createOrder")
    public ResponseEntity<Void> createOrder(@ModelAttribute ServiceOrder serviceOrder){
        log.info("订单——添加订单");
        serviceProviderService.createOrder(serviceOrder);
        return ResponseEntity.ok(null);

    }

}
